import 'package:flutter/material.dart';

import '../../generated/l10n.dart';
import 'gt_center_dialog_widget.dart';

class GTCenterDialog {
  /// 显示中间释义弹窗
  /// title: 标题
  /// contentText: 内容
  /// leftTitle: 取消按钮标题
  /// rightTitle: 确认按钮标题
  static Future<dynamic> showMessageDialog(BuildContext context, String title, String contentText,
      {String? leftText,
      String? rightText,
      GestureTapCallback? onLeftTap,
      GestureTapCallback? onRightTap,
      double? backgroundOpacity}) {
    leftText ??= '';
    return showDialog(
      context: context,
      barrierDismissible: false,
      barrierColor: Color.fromRGBO(0, 0, 0, backgroundOpacity ?? 0.5),
      builder: (context) {
        return GTCenterAlertWidget(
          title: title,
          contentText: contentText,
          isShowClose: true,
          leftText: leftText ?? '',
          rightText: rightText ?? LibUIKitS.of(context).Confirm,
          onLeftTap: onLeftTap,
          onRightTap: onRightTap,
        );
      },
    );
  }

  /// 显示中间取消/确认弹窗
  /// title: 标题
  /// contentText: 内容
  /// leftTitle: 取消按钮标题
  /// rightTitle: 确认按钮标题
  static Future<dynamic> showConfirmDialog(BuildContext context, String title, String contentText,
      {String? leftTitle,
      String? rightTitle,
      bool? isShowClose,
      GestureTapCallback? onLeftTap,
      GestureTapCallback? onRightTap,
      double? backgroundOpacity,
      bool? confirmButtonExpanded,
      bool? isButtonVertical,
      String? alertText}) {
    return showDialog(
      context: context,
      barrierDismissible: false,
      barrierColor: Color.fromRGBO(0, 0, 0, backgroundOpacity ?? 0.5),
      builder: (context) {
        return GTCenterAlertWidget(
            title: title,
            contentText: contentText,
            isShowClose: isShowClose ?? false,
            leftText: leftTitle ?? LibUIKitS.of(context).Cancel,
            rightText: rightTitle ?? LibUIKitS.of(context).Confirm,
            onLeftTap: onLeftTap,
            onRightTap: onRightTap,
            alertText: alertText,
            confirmButtonExpanded: confirmButtonExpanded,
            isButtonVertical: isButtonVertical);
      },
    );
  }
}
